import axios from "axios";
import { put, takeEvery } from "redux-saga/effects";
import { API } from "../../config";
import { Category } from "../../models/category";
import { getCategorySuccess, GET_CATEGORY } from "../actions/category.action";


function* handleGetCategory() {
  const {data} = yield axios.get<Category[]>(`${API}/categories`)
  console.log(data)
  yield put(getCategorySuccess(data))
}

export default function* categorySaga() {
  yield takeEvery(GET_CATEGORY, handleGetCategory) 
}